<?php
namespace RTownley\CustomCollection\Model\ResourceModel;

class Category extends \Magento\Catalog\Model\ResourceModel\Category
{
    public function getProductCount($category)
    {
        $collection = $category->getProductCollection();
        $collection->addAttributeToFilter('onsale', ['eq' => '1']);
        return intval($collection->count());
    }
}